--# HttpTest
    
function setup()
    displayMode(FULLSCREEN)
    spriteMode(CORNER)
    muLu="目录"
    
    textMode(CORNER)
    textAlign(LEFT)
    textWrapWidth(480)
    fontSize(30)
    fill(22, 230, 23, 255)
    
    myImage = image(WIDTH,HEIGHT)
    newImage = image(WIDTH,HEIGHT)
    
    text(muLu,WIDTH/2-30,720)
    rect(WIDTH/2-30,720,3,3)
    textW,textH = textSize(muLu)
    
    myImage:copy(WIDTH/2-30,720,textW,textH)
    
    
    img = makeImage()
    
    r,g,b,a=img:get(300,300)
    print(r,g,b,a)
    
    -- img = myDraw()
    imgMenu = drawMenu()

end

function draw()
        

    
    sprite(img,0,0)
    sprite(imgMenu,WIDTH*31/32,0)
end

function drawMenu()
    -- draw button retuen to indexUI 
    local imgMenu = image(WIDTH/32,HEIGHT)
    -- local imgMenu = image(WIDTH,HEIGHT)
    
    setContext(imgMenu)
    -- background(0,0,0,0) -- transparent background
    
    pushStyle()
    pushMatrix()
    
    -- stroke(0, 250, 255, 255)
    strokeWidth(1)

    textMode(CORNER)
    textAlign(LEFT)
    fontSize(18)
    strokeWidth(1)
    fill(0, 255, 19, 64)
    
    for i = 1,8,1 do
        -- rect(WIDTH*31/32,HEIGHT-i*HEIGHT/8,WIDTH/32,HEIGHT/8)
        rect(0,HEIGHT-i*HEIGHT/8,WIDTH/32,HEIGHT/8)
    end
    
    fill(0, 255, 190, 255)
    
    textWrapWidth(WIDTH/32)
    
    text("目录",WIDTH*31/32+7,HEIGHT/32)
    text("后页",WIDTH*31/32+7,HEIGHT/8+HEIGHT/32)
    text("前页",WIDTH*31/32+7,HEIGHT*2/8+HEIGHT/32)
    text("训诂",WIDTH*31/32+7,HEIGHT*3/8+HEIGHT/32)
    text("他译",WIDTH*31/32+7,HEIGHT*4/8+HEIGHT/32)
    text("",WIDTH*31/32+7,HEIGHT*5/8+HEIGHT/32)
    text("彖辞",WIDTH*31/32+7,HEIGHT*6/8+HEIGHT/32)
    text("设置",WIDTH*31/32+7,HEIGHT*7/8+HEIGHT/32)
    
    popMatrix()
    popStyle() 
    
    setContext()
    
    return imgMenu
end


function myDraw()
    setContext(myImage)
    sprite("Documents:TaiJi",200,200)
    w,h=spriteSize("Documents:TaiJi")
    -- print(w,h)
    -- myImage=image(w,h)
    
    newImage=myImage:copy(200,200,w,h)
    
    sprite(newImage,300,300)
    sprite(img,600,500)
    w,h=spriteSize(img)
    
    
    -- draw mulu     
    
    --[=[
    for x=WIDTH/2-30,WIDTH/2-30+textW,1 do
        for y =720,720+textH,1 do
            r,g,b,a = myImage:get(x,y)
            myImage:set(x+100,y,r,g,b,a)
            -- print(r,g,b,a)
        end
    end
    --]=]
    
    --print(textW,textH)

    

    -- setContext(myImage)
    --rect(WIDTH/2-30,720,textW,textH)
    -- sprite(myImage,WIDTH*3/4,620)
    
    setContext()
    return myImage
end

function makeImage()
    -- This function makes a red circle
    -- Renders it into an image, and returns the image
    local img = image(600,600)
    ------------------------------------
    -- Use the image as a render target
    setContext(img)
    background(0,0,0,0) -- transparent background
    
    fill(255,0,0)
    ellipse(200,200,200)
    
    fill(2, 255, 0, 255)
    fontSize(50)
    
    pushMatrix()
    scale(0.5,1)
    text(muLu,400,200)
    popMatrix()
    -- Set render target back to screen
    setContext()

    ------------------------------------
    return img
end
